<?php
//这个文件把自定义菜单提交封装成了函数
function https_request($url,$data = null){ 
	$curl = curl_init(); 
	curl_setopt($curl, CURLOPT_URL, $url); 
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); 
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); 
	if (!empty($data)){ 
		curl_setopt($curl, CURLOPT_POST, 1); 
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 
	} 
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
	$output = curl_exec($curl); 
	curl_close($curl); 
	return $output; 
}

$access_token = "27_uVhXzz2Dg5zO7mV00BUwNI4Nf73hkm5UeVSximRc5G9V6rCi8vZuobLTYU1UaAfVUQRDJiOx6bnqMlKT3YFvedR3d-DMtfEHP3sY2dXgdIWlMBlf1FSwx72e8_j105xa7fwxTh4FJ_y15_ogZGBhAHAELG"; 
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$access_token;
$jsonmenu = '{"button":[
	{
	"name":"天气预报",
	"sub_button":[
		{
		"type":"click",
		"name":"北京天气",
		"key":"天气北京"
		},
		{
		"type":"click",
		"name":"上海天气",
		"key":"天气上海"
		},
		{
		"type":"click",
		"name":"广州天气",
		"key":"天气广州"
		},
		{
		"type":"click",
		"name":"深圳天气",
		"key":"天气深圳"
		},
		{
		"type":"view",
		"name":"本地天气",
		"url":"http://m.hao123.com/a/tianqi"
		}]
	},
	{
	"name":"瑞雪",
	"sub_button":[
		{
		"type":"click",
		"name":"公司简介",
		"key":"company"
		},
		{
		"type":"click",
		"name":"趣味游戏",
		"key":"游戏"
		},
		{
		"type":"click",
		"name":"讲个笑话",
		"key":"笑话"
		}]
	}
]}'; 

$result = https_request($url, $jsonmenu); 
echo "<pre>";
print_r($result);
echo "</pre>";
  



?>